import os

import numpy as np
import onnxruntime as ort

from mmcv.ops import get_onnxruntime_op_path



if __name__=='__main__':
    ort_custom_op_path = get_onnxruntime_op_path()
    ort_custom_op_path='/home/wsl/gitee/mmcv/build/lib.linux-x86_64-3.7/mmcv/_ext_ort.cpython-37m-x86_64-linux-gnu.so'
    print(ort_custom_op_path)
    assert os.path.exists(ort_custom_op_path)
    session_options = ort.SessionOptions()
    session_options.register_custom_ops_library(ort_custom_op_path)

    onnx_file = '/home/wsl/gitee/mmdetection/tmp.onnx'
    input_data = np.random.randn(1, 3, 224, 224).astype(np.float32)
    sess = ort.InferenceSession(onnx_file, session_options)
    #sess=ort.InferenceSession('/home/wsl/gitee/mmdetection/tmp.onnx')